package com.appspot.aliga.presentation;

import com.appspot.aliga.League;
import com.appspot.aliga.R;
import com.appspot.aliga.R.id;
import com.appspot.aliga.R.layout;

import android.app.Dialog;
import android.content.Context;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.AdapterView;
import android.widget.AdapterView.OnItemClickListener;
import android.widget.ArrayAdapter;
import android.widget.ListView;
import android.widget.TextView;
import android.widget.Toast;

public class LeagueSelection extends Dialog {

	public LeagueSelection(final Context context) {
		super(context);
		setContentView(R.layout.leage_selection);
		setTitle("Liga Auswahl");

		ListView lv = (ListView) findViewById(R.id.listView1);
		lv.setAdapter(new ArrayAdapter<League>(context, R.layout.list_item,
				League.values()));


		lv.setOnItemClickListener(new OnItemClickListener() {
			public void onItemClick(AdapterView<?> parent, View view,
					int position, long id) {
				Bundle bundle = new Bundle();
				bundle.putInt(AppKeys.KEY_LEAGUE_ID, position+1);
				Intent showLeagueView = new Intent(view.getContext(), LeagueView.class);
				showLeagueView.putExtras(bundle);
				getContext().startActivity(showLeagueView);
			}
		});
	}
}
